package com.linkwechat;

import java.net.InetAddress;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;

import com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration;
import com.linkwechat.common.config.fegin.FeginConfig;

import lombok.extern.slf4j.Slf4j;

/**
 * 启动程序
 *
 * @author ruoyi
 */
@Slf4j
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, PageHelperAutoConfiguration.class})
@MapperScan("com.linkwechat.**.mapper")
@EnableAsync
@EnableFeignClients(defaultConfiguration = FeginConfig.class)
public class LinkWeAuthApplication {
	public static void main(String[] args) throws Exception {
		System.setProperty("file.encoding", "UTF-8");

		Environment env = new SpringApplicationBuilder(LinkWeAuthApplication.class) //
				.properties("spring.config.name:bootstrap", "config/run/bootstrap.yml") //
				.properties("spring.application.name=linkwe-auth").build().run(args).getEnvironment();

		String envPort = env.getProperty("server.port");
		String envContext = env.getProperty("server.contextPath",
				env.getProperty("server.servlet.context-path", env.getProperty("server.servlet.contextPath")));
		String nacos = env.getProperty("spring.cloud.nacos.config.server-addr");
		String namespace = env.getProperty("spring.cloud.nacos.config.namespace");
		// 项目端口
		String port = envPort == null ? "8899" : envPort;
		String context = envContext == null ? "" : envContext;
		String ip = InetAddress.getLocalHost().getHostAddress();
		log.info("------------------Access URLs:----------------------------");
		log.info("Local-API: \thttp://{}:{}{}/doc.html", ip, port, context);
		log.info("nacos-URL: \thttp://{}/nacos/#/configurationManagement?namespace={}", nacos, namespace);
		log.info("----------------------------------------------------------");

        System.out.println("(♥◠‿◠)ﾉﾞ  LinkWe-auth启动成功   ლ(´ڡ`ლ)ﾞ ");

		// System.out.println(JSONUtil.toJsonStr(env));

    }
}
